package com.foo.preprocessing;

import weka.core.Instances;

public class Assigning_Instance_Weights 
{
	/*
	 * Set Arbitrary weights for each instance.
	 * This increases the accuracy of the classifier.
	 */
	public Instances setInstanceWeights(Instances dataInstance)
	{
		try
		{
			double factor = 0.5  / (double) dataInstance.numInstances();
		    for (int i = 0; i < dataInstance.numInstances(); i++) 
		    {
		    	dataInstance.instance(i).setWeight(0.5 + factor*factor*i);
		    }		
		}
		catch(Exception e)
		{
			System.err.println("Exception obtained when setting Instance weight: "+ e.getMessage());
		}
	    return dataInstance;
	}

}
